package eleventh.Runtime类;

import java.io.IOException;

public class 让记事本进程运行5s之后消失 {
    public static void main(String[] args) {
       /* Runtime run = Runtime.getRuntime();// 通过Runtime类的静态方法为其进行实例化操作
        try {
            Process pro = run.exec("notepad.exe");
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            pro.destroyForcibly();  // 结束此进程 但实际并无暖用
        } catch (IOException e) {
            throw new RuntimeException(e);
        }*/


        ProcessBuilder pb = new ProcessBuilder("");

        try {
            Process p = pb.start();
            Thread.sleep(3000);
            p.destroy();
            // p.destroyForcibly();
        } catch (IOException e) {
            throw new RuntimeException(e);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }

    }
}
